package com.hh.releasenode.utils;

import org.apache.commons.lang.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @ClassName RegUtils
 * @Description TODO
 * @Author KunxianLi
 * Date 2020/6/29 17:00
 * Version 1.0
 **/
public class RegUtils {

    /**
     *手机号正则表达式
     **/
    public static final String REG_MOBILE = "0?(13|14|15|18|17)[0-9]{9}";

    /**
     *数字正则表达式
     **/
    public static final String REG_NUMBER = "/^[0-9]+$/";


    /**
     * @Author KunxianLi
     * @Description 验证手机号的合法性
     * @Date 2020/6/29 17:21
     * @Param [mobile]
     * @return boolean
     **/
    public static boolean isRightMobile(String mobile){

        if(StringUtils.isNotBlank(mobile)){
            Pattern r = Pattern.compile(REG_MOBILE);
            Matcher m = r.matcher(mobile);
            return m.matches();
        }
        return false;
    }

    /**
     * @Author KunxianLi
     * @Description 字符串是否全是数字
     * @Date 2020/6/30 15:08
     * @Param [number]
     * @return boolean
     **/
    public static boolean isAllNumbers(String number){
        if(StringUtils.isNotBlank(number)){
            Pattern r = Pattern.compile(REG_NUMBER);
            Matcher m = r.matcher(number);
            return m.matches();
        }
        return false;
    }

}
